package cn.webrx.mapper;

import cn.webrx.entity.Student;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.session.RowBounds;

import java.util.List;
import java.util.Map;

/**
 * <p>功能描述: </p>
 *
 * @author webrx
 * @version 1.0
 * @date 2020-09-15 16:28
 */
public interface StudentMapper {
    @Insert("insert into stu() values(null,#{name},#{score},#{age},#{sex},#{birthday},#{address},#{regtime},#{money},#{dept},#{info})")
    public int save(Student st);

    @Insert("insert into stu(name,score,age,sex) values(#{name},#{score},#{age},#{sex})")

    public int add(@Param("name") String name,@Param("score") int score, @Param("age") int age,@Param("sex") String sex);

    @Insert("insert into stu(name,score,age,sex) values(#{name},#{score},#{age},#{sex})")
    @Options(useGeneratedKeys = true,keyProperty = "id")
    public int insert(Map<String,Object> values);

    @Delete("truncate stu")
    public int deleteAll();

    public int deleteById(int id);

    public int deleteByName(String name);

    @Select("show tables")
    public List<String> showTables();

    @Select("select count(*) from stu")
    public int count();


    @Update("update stu set score=#{ss},age=#{aa} where id=#{ii}")
    public int update(@Param("ii") int id,@Param("ss") int score,@Param("aa") int age);


    public int updates(Student st);

    @Select("select * from stu where id = #{id}")
    public Student queryById(int id);

    public List<Student> queryAll();


    public List<Map<String,Object>> queryMy();

    @Select("select name from stu where id = #{id}")
    public String queryByIds(int id);

    @Select("select * from stu where name like #{name} and sex = #{sex}")
    public List<Student> queryByNameSex(@Param("name") String name,@Param("sex") String sex);


    @Select("select name from stu")
    public List<String> queryNamePage(RowBounds rows);

    @Select("select name from stu limit #{index},#{pagesize}")
    public List<String> queryNamePages(Map<String,Object> map);


    @Select("select name from stu")
    public List<String> queryNames();

}
